Skip to main content

What’s New

Qrvey 8.7
Version 8.7 of the Qrvey platform is now available to customers! This version includes new features including area charts, the ability to pivot and export data, as well as numerous bug fixes and performance improvements.
Learn More
Qrvey 8.6
Version 8.6 of the Qrvey platform is now available to customers. This version includes several new feature enhancements and performance improvements.
Learn More
Required Update for 8.5.1
Attention 8.5.1 customers: for any 8.5.1 instance deployed prior to 08/05/2024, an update is required to ensure you are running the latest images.
Learn More
Qrvey 8.5
Version 8.5 (LTS) of the Qrvey platform is now available to customers. This version includes several new features and performance improvements.
Learn More
End-of-life Schedule
We've added a new article that lists the features and endpoints that have been scheduled for deprecation. All features and endpoints will be supported for (1) year after the release date of the LTS version that contains the alternative.
Learn More
Version: 8.4

Using Data Engine Syntax

Data Engine Syntax mode enables you to create formulas using the syntax of a specific database engine.

For general information on using the Formula Builder interface, see Overview of Formula Builder.

Create a Formula Using Data Engine Syntax Mode

  1. Open the Formula Builder interface and select the Data Engine Syntax (Legacy).

formula-builder-data-engine-syntax-82

  1. Enter a name in the Formula Name box.
  2. To add a function to the formula, type it directly in the editor. A suggestion box displays with columns and functions that fit your text. You may also use the following method:
    • Under Insert Functions, select the function that you want to insert. The description box displays helpful information about the function.

      Note: The Insert Functions section is only available for use with Managed datasets. If you are using a Live Connect dataset, you must use the appropriate syntax supported by that dataset.

    • Click Add to Formula. The formula displays in the Formula box.
  3. To add a column to the formula, type it directly in the editor. A suggestion box displays with columns and functions that fit your text. You may also use the following method:
    • Insert the cursor in the desired location in the formula.
    • Under Insert Columns, click on the column that you want to insert. The column displays in the Formula box.
  4. Continue to add functions and columns until your formula is complete.
  5. Before you can use the formula, you must test it. At any time while building your formula, click Test. The formula will be tested with random values from the dataset. An error displays if the formula has a mistake.
  6. Click Save to save the formula.

Examples

The following examples describe typical scenarios for using formulas.

Extract a month from a date

You can use the dateFormat function to extract a month value from a date. For example, if you want to use the month for the x-axis of a bar chart.

| Function | dateFormat |
| Syntax | dateFormat(date_value, ‘format’) |
| Example | dateFormat([orderDate], ‘MM’) |

Aggregate values of all rows

You can create a formula to calculate the aggregate of all the rows in a column, and then use the result in a calculation. For example, to calculate the percentage of one product’s inventory to all product inventory.

| Function | agg_sum |
| Syntax | agg_sum(value) |
| Example | [quantityInStock]/agg_sum([quantityInStock])*100 |

Concatenate text columns

Formula Builder supports concatenation using the + sign. For example, to create a full name by concatenating the first name and last name columns.

| Function | + |
| Syntax | value1+value2+value3... |
| Example | [contactLastName]+’,’+[contactFirstName] |

Using an “if” statement

You can use “if” and other scripting functions to create more sophisticated formulas. For example, suppose you want to create a formula that determines whether your shipping department shipped customer orders within three days. To do this, you would create an if statement that compares two columns in your ERP system, orderDate and shippedDate. If the order was shipped within three days, it returns the word, “fast”. If not, it returns, “slow”. In the example below, notice that the isNull() statement is used to provide some error-handling by changing a null value into a date value (now).

| Function | if |
| Syntax | if (condition) {return result1;} else {return result2;} |
| Example | if(dateDiff([orderDate],isNull([shippedDate],now()),'DAYS')<=3) {return 'fast';} else {return 'slow';} |

Syntax Reference

This section is a reference for proper syntax of formulas in Data Engine Syntax mode.

Field/Column Syntax

Use [ ] around the field or column name. For example:

[Sales]

Function Syntax

Function names must be in lowercase and must be followed by a bracketed argument list. For example:

sum([Items]) avg([Temp])

Operator Syntax

The following table lists the available operators. Note that normal operator precedence applies.

SymbolOperation
.Apply the function following the dot to the string/text value before the dot.
*Multiplication of two numbers.
/Division of two numbers.
+Addition of two numbers.
-Subtraction of two numbers, or negation of a number.
==Test equality of two values.
>Test if the first value is greater than the second value.
<Test if the first value is less than the second value.
>=Test if the first value is greater than or equal to the second value.
<=Test if the first value is less than or equal to the second value.
!=Test inequality of two values.
^Bitwise exclusive or (XOR) of two values.
ANDLogical and of two values.
ORLogical or of two values.
NOTLogical not of a value.
( )Evaluate the bracketed expression before applying operators to it.

Supported Functions

Data Engine Syntax mode supports the following functions:

Numeric Functions

Formula Mode supports the Elasticsearch Math API.

Text Functions

Formula Mode supports the Elasticsearch Text API.

Date Functions

Supported date functions include:

  • now
  • dateFormat
  • dateParse
  • dateAdd
  • dateSubtract
  • dateDiff
  • dateIsNull

Using dateFormat to display dates and times

The dateFormat function enables you to determine how to display the date and time. For example, the following function:

dateFormat(“07/04/2001”, "EEE, MMM d, ‘’yy")

Returns the following format:

Wed, Jul 4, ‘01

Note: You may use single, or double quotes around the format string.

Note: All dates are treated as GMT.

The following table lists the formatting arguments:

LetterDate or Time ComponentPresentationExamples
GEra designatorTextAD
y, YYearYear1996; 96
MMonth in yearMonthJuly; Jul; 07
wWeek in yearNumber27
WWeek in monthNumber2
DDay in yearNumber189
dDay in monthNumber10
FDay of week in monthNumber2
EDay name in weekTextTuesday; Tue
eDay number of week (1 = Monday, ..., 7 = Sunday)Number1
aAM/PM markerTextPM
HHour in day (0-23)Number0
kHour in day (1-24)Number24
KHour in AM/PM (0-11)Number0
hHour in AM/PM (1-12)Number12
mMinute in hourNumber30
sSecond in minuteNumber55
SMillisecondNumber978
zTime zoneGeneral time zonePST; GMT-08:00
ZTime zoneRFC 822 time zone-0800
xTime zoneiso 8601 time zone-08; -0800; -08:00